#
# Default types for WPP
#

# our basic arithmetic types

DEFINE_SIMPLE_TYPE( XINT64, signed __int64,  ItemLongLongX, "I64x", x, 8);
DEFINE_SIMPLE_TYPE( XXINT64, signed __int64,  ItemLongLongXX, "I64X", X, 8);
DEFINE_SIMPLE_TYPE( OINT64, signed __int64,  ItemLongLongO, "I64o", o, 8);

DEFINE_SIMPLE_TYPE( SBYTE,  signed char,     ItemChar,     "c",   c, 1, win:Int8);
DEFINE_SIMPLE_TYPE( SSHORT, signed short,    ItemShort,    "hd",  h, 2, win:Int16);
DEFINE_SIMPLE_TYPE( SINT,   signed int,      ItemLong,     "d",   d, 4, win:Int32);
DEFINE_SIMPLE_TYPE( SLONG,  signed long,     ItemLong,     "ld",  l, 4, win:Int32);
DEFINE_SIMPLE_TYPE( SINT64, signed __int64,  ItemLongLong, "I64d", i, 8, win:Int64);

DEFINE_SIMPLE_TYPE( UBYTE,  unsigned char,     ItemChar,     "c",   C, 1, win:UInt8);
DEFINE_SIMPLE_TYPE( USHORT, unsigned short,    ItemShort,    "hu",  H, 2, win:UInt16);
DEFINE_SIMPLE_TYPE( UINT,   unsigned int,      ItemLong,     "u",   D, 4, win:UInt32);
DEFINE_SIMPLE_TYPE( ULONG,  unsigned long,     ItemLong,     "lu",  L, 4, win:UInt32);
DEFINE_SIMPLE_TYPE( UINT64, unsigned __int64,  ItemULongLong, "I64u", I, 8, win:UInt64);

DEFINE_SIMPLE_TYPE( DOUBLE, double,  ItemDouble, "s", g, 8, win:Double);

# arch dependent types

DEFINE_SIMPLE_TYPE( SLONGPTR, LONG_PTR,     ItemPtr,  "Id", p, 6, win:Pointer);
DEFINE_SIMPLE_TYPE( ULONGPTR, ULONG_PTR,    ItemPtr,  "Iu", P, 6, win:Pointer);
DEFINE_SIMPLE_TYPE( PTR,      const void*,  ItemPtr,  "p", q, 6, win:Pointer);
DEFINE_SIMPLE_TYPE( HANDLE,   const void*,  ItemPtr,  "p", Q, 6, win:Pointer);

# predefined constants

DEFINE_SIMPLE_TYPE( COMPNAME,,, "__COMPNAME__",,);
DEFINE_SIMPLE_TYPE( FILE,,, "__FILE__",,);
DEFINE_SIMPLE_TYPE( LINE,,, "__LINE__",,);
DEFINE_SIMPLE_TYPE( FUNC,,, "%!FUNC!",,); // traceprt now understands %!FUNC!
DEFINE_SIMPLE_TYPE( LEVEL,,, "%!LEVEL!",,); // and %!LEVEL%

DEFINE_SIMPLE_TYPE( STDPREFIX,,, "%0",,);
DEFINE_SIMPLE_TYPE( MOD,,, "%1!s!",,);
DEFINE_SIMPLE_TYPE( TYP,,, "%2!s!",,);
DEFINE_SIMPLE_TYPE( TID,,, "%3!x!",,);
DEFINE_SIMPLE_TYPE( NOW,,, "%4!s!",,);
DEFINE_SIMPLE_TYPE( SEQ,,, "%7!x!",,);
DEFINE_SIMPLE_TYPE( PID,,, "%8!x!",,);
DEFINE_SIMPLE_TYPE( CPU,,, "%9!x!",,);
DEFINE_SIMPLE_TYPE( SPACE,,, " ",,);

DEFINE_SIMPLE_TYPE_PTR(GUID, LPCGUID, ItemGuid, "s", _guid_, 0, win:GUID, win:GUID); // simple type, passed by addr

DEFINE_FLAVOR( UCHAR,   SBYTE, ItemUChar, "c" );
DEFINE_FLAVOR( SCHAR,   SBYTE, ItemChar,  "c" );
DEFINE_FLAVOR( BOOLEAN, SBYTE, ItemListByte(FALSE,TRUE), "s");


# all strings require custom processing

DEFINE_CPLX_TYPE(ASTR,  WPP_LOGASTR,  const char*,     ItemString,  "hs", s, 0, win:AnsiString);
DEFINE_CPLX_TYPE(ARSTR, WPP_LOGASTR,  LPCSTR,          ItemRString, "hs", t, 0, win:AnsiString);
DEFINE_CPLX_TYPE(ARWSTR, WPP_LOGWSTR, LPCWSTR,        ItemRWString, "ls", S, 0, win:UnicodeString);
DEFINE_CPLX_TYPE(WSTR,  WPP_LOGWSTR,  LPCWSTR,         ItemWString, "ls", S, 0, win:UnicodeString);
DEFINE_CPLX_TYPE(CSTR,  WPP_LOGPCSTR, PCSTRING,        ItemPString, "hs", z, 0, 2);
DEFINE_CPLX_TYPE(USTR,  WPP_LOGPUSTR, PCUNICODE_STRING,ItemPWString,"ls", Z, 0, 2);
DEFINE_CPLX_TYPE(ANSTR,  WPP_LOGPCSTR, PCANSI_STRING,   ItemPString, "hs", aZ, 0, 2);

DEFINE_CPLX_TYPE(sid,   WPP_LOGPSID, PSID, ItemSid,"s", _sid_, 0);
DEFINE_CPLX_TYPE(str,   WPP_LOGSTDSTR, const std::string&, ItemString,"s", _str_, 0);


#kludge for printf like statements

DEFINE_FLAVOR(e,  DOUBLE,,);
DEFINE_FLAVOR(E,  DOUBLE,,);
DEFINE_FLAVOR(f,  DOUBLE,,);
DEFINE_FLAVOR(g,  DOUBLE,,);
DEFINE_FLAVOR(G,  DOUBLE,,);

DEFINE_FLAVOR(c,  SBYTE,,);
DEFINE_FLAVOR(hc, SBYTE,,);
DEFINE_FLAVOR(lc, SSHORT,,);
DEFINE_FLAVOR(wc, SSHORT,,);
DEFINE_FLAVOR(C,  SSHORT,,);

DEFINE_FLAVOR(s,  ASTR,,);
DEFINE_FLAVOR(hs, ASTR,,);
DEFINE_FLAVOR(S,  WSTR,,);
DEFINE_FLAVOR(ws, WSTR,,);
DEFINE_FLAVOR(ls, WSTR,,);

DEFINE_FLAVOR(hi, SSHORT,,);
DEFINE_FLAVOR(hd, SSHORT,,);
DEFINE_FLAVOR(hu, USHORT,,"u");
DEFINE_FLAVOR(hx, USHORT,,"x");
DEFINE_FLAVOR(hX, USHORT,,"X");
DEFINE_FLAVOR(ho, USHORT,,"o");

DEFINE_FLAVOR(Id, ULONGPTR,,"Id");
DEFINE_FLAVOR(Iu, ULONGPTR,,"Iu");
DEFINE_FLAVOR(Ix, ULONGPTR,,"Ix");
DEFINE_FLAVOR(IX, ULONGPTR,,"IX");
DEFINE_FLAVOR(Io, ULONGPTR,,"Io");

DEFINE_FLAVOR(i, SINT,,);
DEFINE_FLAVOR(d, SINT,,);
DEFINE_FLAVOR(u, UINT,,"u");
DEFINE_FLAVOR(x, UINT,,"x");
DEFINE_FLAVOR(X, UINT,,"X");
DEFINE_FLAVOR(o, UINT,,"o");
DEFINE_FLAVOR(cccc, SINT, ItemChar4, "s");

DEFINE_FLAVOR(li, SLONG,,);
DEFINE_FLAVOR(ld, SLONG,,);
DEFINE_FLAVOR(lu, ULONG,,"u");
DEFINE_FLAVOR(lx, ULONG,,"x");
DEFINE_FLAVOR(lX, ULONG,,"X");
DEFINE_FLAVOR(lo, ULONG,,"o");

DEFINE_FLAVOR(I64d, SINT64,,);
DEFINE_FLAVOR(I64u, UINT64,,);
DEFINE_FLAVOR(I64x, XINT64,,"I64x");
DEFINE_FLAVOR(I64X, XXINT64,,"I64X");
DEFINE_FLAVOR(I64o, OINT64,,"I64o");

DEFINE_FLAVOR(lld, SINT64,,);
DEFINE_FLAVOR(llu, UINT64,,);
DEFINE_FLAVOR(llx, XINT64,,"I64x");
DEFINE_FLAVOR(llX, XXINT64,,"I64X");
DEFINE_FLAVOR(llo, OINT64,,"I64o");


DEFINE_FLAVOR(p, PTR,,);

DEFINE_FLAVOR(Z,  ANSTR,,);
DEFINE_FLAVOR(wZ, USTR,,);
DEFINE_FLAVOR(z,  CSTR,,);
DEFINE_FLAVOR(hZ, CSTR,,);

# default formats for those who don't care to provide their own strings

DEFINE_FLAVOR(XBYTE, SBYTE,, "02x");
DEFINE_FLAVOR(OBYTE, SBYTE,, "o");

DEFINE_FLAVOR(XSHORT, SSHORT,, "04hX");
DEFINE_FLAVOR(OSHORT, SSHORT,, "ho");

DEFINE_FLAVOR(XINT, SINT,, "08x");
DEFINE_FLAVOR(OINT, SINT,, "o");

DEFINE_FLAVOR(XLONG, SLONG,, "08lX");
DEFINE_FLAVOR(OLONG, SLONG,, "lo");


DEFINE_FLAVOR(XLONGPTR, SLONGPTR,,"Ix");
DEFINE_FLAVOR(OLONGPTR, SLONGPTR,,"Ox");

# special formats

DEFINE_FLAVOR(IPADDR,      UINT,   ItemIPAddr,      "s");
DEFINE_FLAVOR(PORT,        USHORT, ItemPort,        "s");
DEFINE_FLAVOR(STATUS,      SINT,   ItemNTSTATUS,    "s");
DEFINE_FLAVOR(WINERROR,    UINT,   ItemWINERROR,    "s");
DEFINE_FLAVOR(HRESULT,     SINT,   ItemHRESULT,     "s", win:HResult);
DEFINE_FLAVOR(NDIS_STATUS, SINT,   ItemNDIS_STATUS, "s");

DEFINE_FLAVOR(ipaddr,IPADDR,,);
DEFINE_FLAVOR(port,PORT,,);
DEFINE_FLAVOR(status,STATUS,,);
DEFINE_FLAVOR(hresult,HRESULT,,);
DEFINE_FLAVOR(winerr,WINERROR,,);
DEFINE_FLAVOR(guid,GUID,,);

# time related stuff

DEFINE_FLAVOR(TIMESTAMP, SINT64, ItemTimestamp, "s");
DEFINE_FLAVOR(TIME,      SINT64, ItemTimestamp, "s");
DEFINE_FLAVOR(DATE,      SINT64, ItemTimestamp, "s");
DEFINE_FLAVOR(WAITTIME,  SINT64, ItemTimestamp, "s");

DEFINE_FLAVOR(due,      SINT64, ItemWaitTime, "s");
DEFINE_FLAVOR(delta,    SINT64, ItemTimeDelta, "s");
DEFINE_FLAVOR(datetime, SINT64, ItemTimestamp, "s");

# enumeration types

DEFINE_FLAVOR(ItemListByte,  SBYTE, ItemListByte, "s");
DEFINE_FLAVOR(ItemListShort, SSHORT, ItemListShort,"s");
DEFINE_FLAVOR(ItemListLong,  SLONG, ItemListLong, "s");

DEFINE_FLAVOR(ItemSetByte,  UBYTE, ItemSetByte, "s");
DEFINE_FLAVOR(ItemSetShort, USHORT, ItemSetShort,"s");
DEFINE_FLAVOR(ItemSetLong,  ULONG, ItemSetLong, "s");

DEFINE_FLAVOR(ItemEnum, ULONG, ItemEnum, "s");
DEFINE_FLAVOR(ItemFlagsEnum, ULONG, ItemFlagsEnum, "s");

DEFINE_FLAVOR(CLSID, GUID, ItemCLSID,  "s");
DEFINE_FLAVOR(LIBID, GUID, ItemLIBID,  "s");
DEFINE_FLAVOR(IID,   GUID, ItemIID,    "s");


CUSTOM_TYPE(b1,  ItemSetByte(1,2,3,4,5,6,7,8) );
CUSTOM_TYPE(b2,  ItemSetShort(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) );
CUSTOM_TYPE(b4,  ItemSetLong(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32) );


CUSTOM_TYPE(bool,    ItemListLong(false,true) );
CUSTOM_TYPE(bool16,  ItemListShort(false,true) );
CUSTOM_TYPE(bool8,   ItemListByte(false,true) );

CUSTOM_TYPE(irql,    ItemListByte(Low,APC,DPC) );

CUSTOM_TYPE(pnpmn,   ItemListByte(IRP_MN_START_DEVICE,IRP_MN_QUERY_REMOVE_DEVICE,IRP_MN_REMOVE_DEVICE,IRP_MN_CANCEL_REMOVE_DEVICE,IRP_MN_STOP_DEVICE,IRP_MN_QUERY_STOP_DEVICE,IRP_MN_CANCEL_STOP_DEVICE,IRP_MN_QUERY_DEVICE_RELATIONS,IRP_MN_QUERY_INTERFACE,IRP_MN_QUERY_CAPABILITIES,IRP_MN_QUERY_RESOURCES,IRP_MN_QUERY_RESOURCE_REQUIREMENTS,IRP_MN_QUERY_DEVICE_TEXT,IRP_MN_FILTER_RESOURCE_REQUIREMENTS,IRP_MN_PNP_14,IRP_MN_READ_CONFIG,IRP_MN_WRITE_CONFIG,IRP_MN_EJECT,IRP_MN_SET_LOCK,IRP_MN_QUERY_ID,IRP_MN_QUERY_PNP_DEVICE_STATE,IRP_MN_QUERY_BUS_INFORMATION,IRP_MN_DEVICE_USAGE_NOTIFICATION,IRP_MN_SURPRISE_REMOVAL) );
CUSTOM_TYPE(sysctrl, ItemListByte(IRP_MN_QUERY_ALL_DATA,IRP_MN_QUERY_SINGLE_INSTANCE, IRP_MN_CHANGE_SINGLE_INSTANCE, IRP_MN_CHANGE_SINGLE_ITEM, IRP_MN_ENABLE_EVENTS, IRP_MN_DISABLE_EVENTS, IRP_MN_ENABLE_COLLECTION, IRP_MN_DISABLE_COLLECTION, IRP_MN_REGINFO, IRP_MN_EXECUTE_METHOD, IRP_MN_Reserved_0a, IRP_MN_REGINFO_EX) );
CUSTOM_TYPE(pnpmj,   ItemListByte(IRP_MJ_CREATE,IRP_MJ_CREATE_NAMED_PIPE,IRP_MJ_CLOSE,IRP_MJ_READ,IRP_MJ_WRITE,IRP_MJ_QUERY_INFORMATION,IRP_MJ_SET_INFORMATION,IRP_MJ_QUERY_EA,IRP_MJ_SET_EA,IRP_MJ_FLUSH_BUFFERS,IRP_MJ_QUERY_VOLUME_INFORMATION,IRP_MJ_SET_VOLUME_INFORMATION,IRP_MJ_DIRECTORY_CONTROL,IRP_MJ_FILE_SYSTEM_CONTROL,IRP_MJ_DEVICE_CONTROL,IRP_MJ_INTERNAL_DEVICE_CONTROL,IRP_MJ_SHUTDOWN,IRP_MJ_LOCK_CONTROL,IRP_MJ_CLEANUP,IRP_MJ_CREATE_MAILSLOT,IRP_MJ_QUERY_SECURITY,IRP_MJ_SET_SECURITY,IRP_MJ_POWER,IRP_MJ_SYSTEM_CONTROL,IRP_MJ_DEVICE_CHANGE,IRP_MJ_QUERY_QUOTA,IRP_MJ_SET_QUOTA,IRP_MJ_PNP) );

# default tracing macro

FUNC DoTraceMessage(LEVEL,MSG,...);
FUNC DoDebugTrace(TRACELEVEL,MSG,...);

# default prefix (use traceprt default)

USEPREFIX(*,"%!STDPREFIX!"); // traceprt will add standard prefix

WPP_FLAGS(-lookfor:WPP_INIT_TRACING); // the same flags that can be passed on the command line to tracewpp
